package com.ygxsk.carhome.ui.adapter;

import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.cardview.widget.CardView;

import com.blankj.utilcode.util.ColorUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.constant.ExtraValue;
import com.ygxsk.carhome.response.BookingInsideBean;
import com.ygxsk.carhome.utils.CommUtils;

import java.util.List;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-09-09  17:14
 * @Description:关于预约的内部的九宫格布局；
 */
public class BookingInsideAdapter extends BaseQuickAdapter<BookingInsideBean, BaseViewHolder> {

    private int come_from_where;

    public BookingInsideAdapter(int layoutResId, @Nullable List<BookingInsideBean> data) {
        super(layoutResId, data);
    }

    public BookingInsideAdapter(int layoutResId, @Nullable List<BookingInsideBean> data, int _from_where) {
        super(layoutResId, data);
        this.come_from_where = _from_where;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, BookingInsideBean bookingInsideBean) {

        if (bookingInsideBean != null) {

//            int timePeriodId = bookingInsideBean.getSiteTimeSpanId();
            String timePeriodValue = bookingInsideBean.getTimeSpanLabel();
//            String timePeriodValue = "8:00-9:10";
            //该时间段  是否可用；
            boolean usable = bookingInsideBean.isUsable();
            boolean isChecked = bookingInsideBean.isChecked();

            //开始时间  后边可能和当前时间做对比，如果不在营业时间，就关闭；
            String rentBeginTime = bookingInsideBean.getRentBeginTime();
            //结束时间
//            String rentEndTime =bookingInsideBean.getRentEndTime();

            //价格
//            BigDecimal bigDecimal =  bookingInsideBean.get()


            TextView textViewTimeCheck = (TextView) baseViewHolder.getView(R.id.textViewTimeCheck);

            //价格信息
//            TextView textViewTimeCheckPrice = (TextView) baseViewHolder.getView(R.id.textViewTimeCheckPrice);

            //开始时间
//            TextView textViewTimeCheckBeginTime = (TextView) baseViewHolder.getView(R.id.textViewTimeCheckBeginTime);
            //结束时间
//            TextView textViewTimeCheckEndTime = (TextView) baseViewHolder.getView(R.id.textViewTimeCheckEndTime);

//            CommUtils.setText(textViewTimeCheckBeginTime,rentBeginTime);
//            CommUtils.setText(textViewTimeCheckEndTime,rentEndTime);

            CommUtils.setText(textViewTimeCheck, timePeriodValue);

            //cardView
            CardView card_view_in_booking_inside = (CardView) baseViewHolder.getView(R.id.card_view_in_booking_inside);


//          textViewTimeCheck.setText(timePeriodValue);


            if (come_from_where == ExtraValue.COME_FROM_PAINT_BOOKING_MAIN_ACTIVITY) {

                //如果是从正常的选择喷涂房过来的，需要判断这个字段

                //如果该时间段 可用
                if (usable) {

                    if (isChecked) {
                        textViewTimeCheck.setTextColor(ColorUtils.getColor(R.color.black));
                        card_view_in_booking_inside.setCardBackgroundColor(ColorUtils.getColor(R.color.green));
                    } else {
//                        textViewTimeCheck.setTextColor(ColorUtils.getColor(R.color.bluesknomal));
                        textViewTimeCheck.setTextColor(ColorUtils.getColor(R.color.headmanblue));
                        card_view_in_booking_inside.setCardBackgroundColor(ColorUtils.getColor(R.color.white));
                    }

                } else {

                    //文字设置为灰色
                    textViewTimeCheck.setTextColor(ColorUtils.getColor(R.color.gray28));
                    card_view_in_booking_inside.setCardBackgroundColor(ColorUtils.getColor(R.color.gray02));

                }

            } else if (come_from_where == ExtraValue.COME_FROM_PAINT_BOOKING_FEE_ACTIVITY) {//如果是从结算页过来的

                //文字蓝色
//                textViewTimeCheck.setTextColor(ColorUtils.getColor(R.color.bluesknomal));
                textViewTimeCheck.setTextColor(ColorUtils.getColor(R.color.headmanblue));
                //背景白色
                card_view_in_booking_inside.setCardBackgroundColor(ColorUtils.getColor(R.color.white));

            }

        }
    }
}
